package behavioral.state;

public class CourseVideoContext {

    private CourseVideoState courseVideoState;
    //可以通过享元模式来共享同一个变量，所以 要final 和static
    public final static PlayState PLAY_STATE = new PlayState();
    public final static StopState STOP_STATE = new StopState();
    public final static PauseState PAUSE_STATE = new PauseState();
    public final static SpeedState SPEED_STATE = new SpeedState();

    public CourseVideoState getCourseVideoState(){
        return courseVideoState;
    }
    public void setCourseVideoState(CourseVideoState courseVideoState){
        this.courseVideoState = courseVideoState;

        //把当前这个环境（就是上下文），，通知到各个实现类。
        this.courseVideoState.setCourseVideoContext(this);
    }

    public void play(){
        //上下文想要play 的话 ，只要调用这个状态的play就行了
        this.courseVideoState.play();
    }

    public void stop(){
        this.courseVideoState.stop();
    }

    public void speed(){
        this.courseVideoState.speed();
    }

    public void pause(){
        this.courseVideoState.pause();
    }

}
